package com.windoent.yugioh.adapter.brvah;

import android.widget.CheckBox;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.windoent.yugioh.R;
import com.windoent.yugioh.bean.GoodsAddressListBean;
import com.windoent.yugioh.utils.BaseMethod;

/**
 * author : robert
 * date   : 2021/5/6 15:26
 * desc   :
 */
public class SeasonRewardAddressAdapter extends BaseQuickAdapter<GoodsAddressListBean.DataBean.ResBean, BaseViewHolder> {
    private int position = 0;

    public SeasonRewardAddressAdapter() {
        super(R.layout.item_list_season_reward_address, null);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, GoodsAddressListBean.DataBean.ResBean item) {
        helper.setText(R.id.tv_name, BaseMethod.notNullDefaultValueNull(item.getName()))
                .setText(R.id.tv_phone, BaseMethod.notNullDefaultValueNull(item.getTelephone()))
                .setText(R.id.tv_content, BaseMethod.notNullDefaultValueNull(item.getAddress()))
        ;
        CheckBox check_box = helper.getView(R.id.check_box);
        int layoutPosition = helper.getLayoutPosition();
        check_box.setChecked(position == layoutPosition);
    }

    public void setPosition(int position) {
        this.position = position;
        notifyDataSetChanged();
    }

}